
runtestes_paralelo() {

	N=$1
	FILEIN=$2
	FILEOUT=$3
	METODO=$4
	NTHREADS=$5

	echo StartTime >> $FILEOUT
	date >> $FILEOUT
	echo Running $N parallel tests IN: $FILEIN OUT: $FILEOUT METODO: $METODO THREADS: $NTHREADS >> $FILEOUT
	
	TIMEFORMAT='%3R';
	for ((c=1; c<=N; c++))
	do
		time (./hosp $METODO $NTHREADS < $FILEIN >> $FILEOUT ) 2>> $FILEOUT
	done

	echo EndTime >> $FILEOUT
	date >> $FILEOUT
	echo "####################################################################################" >> $FILEOUT
	
	#Formatar Saida
	OUTFILE2="f_"$FILEOUT
	awk 'BEGIN {ss=0;x=0;} { ss=($1 ~ /[0-9]+/); if(ss==1){if (x==0){printf ss $0; x=1}else{printf "\t"$0"\n"; x=0}}else{print} }' $FILEOUT > $OUTFILE2
}


runtestes_sequencial() {

	N=$1
	FILEIN=$2
	FILEOUT=$3

	echo StartTime >> $FILEOUT
	date >> $FILEOUT
	echo Running $N sequential tests IN: $FILEIN OUT: $FILEOUT >> $FILEOUT
	
	TIMEFORMAT='%3R';
	for ((c=1; c<=N; c++))
	do
		time (./hosp 0 0 < $FILEIN >> $FILEOUT) 2>> $FILEOUT
	done

	echo EndTime >> $FILEOUT
	date >> $FILEOUT
	echo "####################################################################################" >> $FILEOUT
	
	#Formatar Saida
	OUTFILE2="f_"$FILEOUT
	awk 'BEGIN {ss=0;x=0;} { ss=($1 ~ /[0-9]+/); if(ss==1){if (x==0){printf $0; x=1}else{printf "\t"$0"\n"; x=0}}else{print} }' $FILEOUT > $OUTFILE2
}

# SEQUENCIAL
# num_tests input output threads
# runtestes_sequencial 10 input01 exectimes_s.txt
# runtestes_sequencial 10 input05 exectimes_s.txt
# runtestes_sequencial 10 input10 exectimes_s.txt

# PARALELO
# num_tests input output metodo threads

#METODO 1
#runtestes_paralelo 10 input01 exectimes_p1.txt 1 2
#runtestes_paralelo 10 input01 exectimes_p1.txt 1 4
#runtestes_paralelo 10 input01 exectimes_p1.txt 1 8
#runtestes_paralelo 10 input01 exectimes_p1.txt 1 16

#runtestes_paralelo 10 input05 exectimes_p1.txt 1 2
#runtestes_paralelo 10 input05 exectimes_p1.txt 1 4
#runtestes_paralelo 10 input05 exectimes_p1.txt 1 8
#runtestes_paralelo 10 input05 exectimes_p1.txt 1 16

#runtestes_paralelo 10 input10 exectimes_p1.txt 1 2
#runtestes_paralelo 10 input10 exectimes_p1.txt 1 4
#runtestes_paralelo 10 input10 exectimes_p1.txt 1 8
#runtestes_paralelo 10 input10 exectimes_p1.txt 1 16

# METODO 2
#runtestes_paralelo 5 input01 exectimes_p2.txt 2 2
#runtestes_paralelo 5 input01 exectimes_p2.txt 2 4
#runtestes_paralelo 5 input01 exectimes_p2.txt 2 8
#runtestes_paralelo 5 input01 exectimes_p2.txt 2 16

#runtestes_paralelo 5 input05 exectimes_p2.txt 2 2
#runtestes_paralelo 5 input05 exectimes_p2.txt 2 4
#runtestes_paralelo 5 input05 exectimes_p2.txt 2 8
#runtestes_paralelo 5 input05 exectimes_p2.txt 2 16

#runtestes_paralelo 5 input10 exectimes_p2.txt 2 2
#runtestes_paralelo 5 input10 exectimes_p2.txt 2 4
#runtestes_paralelo 5 input10 exectimes_p2.txt 2 8
#runtestes_paralelo 5 input10 exectimes_p2.txt 2 16

# METODO 3
runtestes_paralelo 5 input01 exectimes_p3.txt 3 2
runtestes_paralelo 5 input01 exectimes_p3.txt 3 4
runtestes_paralelo 5 input01 exectimes_p3.txt 3 8
runtestes_paralelo 5 input01 exectimes_p3.txt 3 16

#runtestes_paralelo 5 input05 exectimes_p3.txt 3 2
#runtestes_paralelo 5 input05 exectimes_p3.txt 3 4
#runtestes_paralelo 5 input05 exectimes_p3.txt 3 8
#runtestes_paralelo 5 input05 exectimes_p3.txt 3 16

runtestes_paralelo 5 input10 exectimes_p3.txt 3 2
runtestes_paralelo 5 input10 exectimes_p3.txt 3 4
runtestes_paralelo 5 input10 exectimes_p3.txt 3 8
runtestes_paralelo 5 input10 exectimes_p3.txt 3 16
